package com.ziven.common.widget.value;

import android.view.View;

import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;

import com.ziven.common.widget.WidgetUtils;
import com.ziven.easygo.util.ResourceUtils;
import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public final class Width extends Value {

    public static Width dimenId(@DimenRes int dimenId) {
        return size(ResourceUtils.getDimen(dimenId));
    }

    public static Width size(@NonNull String dp) {
        return size(WidgetUtils.dimenInt(dp));
    }

    public static Width size(int size) {
        return new Width().accept(my -> my.value = size);
    }

    private Width() {}

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        value(Integer.class, helper::setWidth);
    }
}
